<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next-haha.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next-haha.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next-haha.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.0/css/all.min.css" integrity="sha256-VHqXKFhhMxcpubYf9xiWdCiojEbY9NexQ4jh8AxbvcM=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"ming.theyan.gs","root":"/","images":"/images","scheme":"Pisces","darkmode":false,"version":"8.25.0","exturl":false,"sidebar":{"position":"left","width_expanded":320,"width_dual_column":240,"display":"post","padding":18,"offset":12},"hljswrap":true,"codeblock":{"theme":{"light":"default","dark":"stackoverflow-dark"},"prism":{"light":"prism","dark":"prism-dark"},"copy_button":{"enable":false,"style":null},"fold":{"enable":false,"height":500},"language":false},"bookmark":{"enable":true,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"duration":200,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"top_n_per_article":1,"unescape":false,"preload":false,"trigger":"auto"}}</script><script src="/js/config.js" defer></script>

    <meta name="description" content="什么是IPv6Internet Protocol version 6 (简称IPv6) 是 Internet Protocol（互联网协议） (IP)的最新一个版本，IPv6主要是为了解决IPv4地址枯竭的问题而开发的，目的是为了替换当前所用的IPv4。 虽然IPv6天生是为了替代IPv4的（生而自豪），而且最近几年IPv4地址也已然分配完，但是由于NAT这种技术的存在，使得IPv6还没有真正意义">
<meta property="og:type" content="article">
<meta property="og:title" content="CentOS下怎样干掉IPv6">
<meta property="og:url" content="https://ming.theyan.gs/2016/08/CentOS%E4%B8%8B%E6%80%8E%E6%A0%B7%E5%B9%B2%E6%8E%89IPv6/index.html">
<meta property="og:site_name" content="运维烂笔头">
<meta property="og:description" content="什么是IPv6Internet Protocol version 6 (简称IPv6) 是 Internet Protocol（互联网协议） (IP)的最新一个版本，IPv6主要是为了解决IPv4地址枯竭的问题而开发的，目的是为了替换当前所用的IPv4。 虽然IPv6天生是为了替代IPv4的（生而自豪），而且最近几年IPv4地址也已然分配完，但是由于NAT这种技术的存在，使得IPv6还没有真正意义">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2016-08-31T07:49:24.000Z">
<meta property="article:modified_time" content="2019-04-04T23:47:06.999Z">
<meta property="article:author" content="老杨">
<meta property="article:tag" content="CentOS">
<meta property="article:tag" content="IPv6">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="https://ming.theyan.gs/2016/08/CentOS%E4%B8%8B%E6%80%8E%E6%A0%B7%E5%B9%B2%E6%8E%89IPv6/">


<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://ming.theyan.gs/2016/08/CentOS%E4%B8%8B%E6%80%8E%E6%A0%B7%E5%B9%B2%E6%8E%89IPv6/index.html","path":"2016/08/CentOS下怎样干掉IPv6/index.html","title":"CentOS下怎样干掉IPv6"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>CentOS下怎样干掉IPv6 | 运维烂笔头</title>
  
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-106574959-2"></script>
  <script class="next-config" data-name="google_analytics" type="application/json">{"tracking_id":"UA-106574959-2","only_pageview":false,"measure_protocol_api_secret":null}</script>
  <script src="/js/third-party/analytics/google-analytics.js" defer></script>

  <script src="/js/third-party/analytics/baidu-analytics.js" defer></script>
  <script async src="https://hm.baidu.com/hm.js?fdef9ded31bdb8b2dab08eddebdd5fed"></script>







  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous" defer></script>
<script src="/js/utils.js" defer></script><script src="/js/motion.js" defer></script><script src="/js/sidebar.js" defer></script><script src="/js/next-boot.js" defer></script><script src="/js/bookmark.js" defer></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.5.0/search.js" integrity="sha256-xFC6PJ82SL9b3WkGjFavNiA9gm5z6UBxWPiu4CYjptg=" crossorigin="anonymous" defer></script>
<script src="/js/third-party/search/local-search.js" defer></script>







  




<!-- google adsense -->
<script data-ad-client="ca-pub-1045025618858716" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<link rel="alternate" href="/atom.xml" title="运维烂笔头" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">运维烂笔头</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">一个 SA 老兵的工作日志</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-projects"><a href="/projects" rel="section"><i class="fa fa-code fa-fw"></i>projects</a></li><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li><li class="menu-item menu-item-sitemap"><a href="/sitemap.xml" rel="section"><i class="fa fa-sitemap fa-fw"></i>站点地图</a></li><li class="menu-item menu-item-commonweal"><a href="/404/" rel="section"><i class="fa fa-heartbeat fa-fw"></i>公益 404</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
      <div class="search-header">
        <span class="search-icon">
          <i class="fa fa-search"></i>
        </span>
        <div class="search-input-container">
          <input autocomplete="off" autocapitalize="off" maxlength="80"
                placeholder="搜索..." spellcheck="false"
                type="search" class="search-input">
        </div>
        <span class="popup-btn-close" role="button">
          <i class="fa fa-times-circle"></i>
        </span>
      </div>
      <div class="search-result-container">
        <div class="search-result-icon">
          <i class="fa fa-spinner fa-pulse fa-5x"></i>
        </div>
      </div>
    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BB%80%E4%B9%88%E6%98%AFIPv6"><span class="nav-number">1.</span> <span class="nav-text">什么是IPv6</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#IPv6%E7%9A%84%E6%AF%9B%E7%97%85"><span class="nav-number">2.</span> <span class="nav-text">IPv6的毛病</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%87%A0%E7%A7%8D%E5%A7%BF%E5%8A%BF"><span class="nav-number">3.</span> <span class="nav-text">几种姿势</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#sysctl%E5%A4%A7%E6%B3%95"><span class="nav-number">3.1.</span> <span class="nav-text">sysctl大法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#modprobe%E5%8A%AB%E6%8C%81"><span class="nav-number">3.2.</span> <span class="nav-text">modprobe劫持</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#GRUB%E5%8F%82%E6%95%B0"><span class="nav-number">3.3.</span> <span class="nav-text">GRUB参数</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%AA%E4%BA%BA%E6%8E%A8%E8%8D%90%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88"><span class="nav-number">4.</span> <span class="nav-text">个人推荐的解决方案</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">老杨</p>
  <div class="site-description" itemprop="description">好记性比不过烂笔头</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">114</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">8</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">509</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/haw-haw" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;haw-haw" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:blog@theyan.gs" title="E-Mail → mailto:blog@theyan.gs" rel="noopener me" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://weibo.com/u/1494877243" title="Weibo → https:&#x2F;&#x2F;weibo.com&#x2F;u&#x2F;1494877243" rel="noopener me" target="_blank"><i class="fab fa-weibo fa-fw"></i>Weibo</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://twitter.com/6fool" title="Twitter → https:&#x2F;&#x2F;twitter.com&#x2F;6fool" rel="noopener me" target="_blank"><i class="fab fa-twitter fa-fw"></i>Twitter</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
    <div class="sidebar-inner sidebar-blogroll">
      <div class="links-of-blogroll animated">
        <div class="links-of-blogroll-title"><i class="fa fa-globe fa-fw"></i>
          链接
        </div>
        <ul class="links-of-blogroll-list">
            <li class="links-of-blogroll-item">
              <a href="https://bad-pencil.github.io/" title="https:&#x2F;&#x2F;bad-pencil.github.io" rel="noopener" target="_blank">github 镜像站</a>
            </li>
            <li class="links-of-blogroll-item">
              <a href="https://hawhaw.gitee.io/" title="https:&#x2F;&#x2F;hawhaw.gitee.io" rel="noopener" target="_blank">gitee 镜像站</a>
            </li>
        </ul>
      </div>
    </div>
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://ming.theyan.gs/2016/08/CentOS%E4%B8%8B%E6%80%8E%E6%A0%B7%E5%B9%B2%E6%8E%89IPv6/index.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="老杨">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="运维烂笔头">
      <meta itemprop="description" content="好记性比不过烂笔头">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="CentOS下怎样干掉IPv6 | 运维烂笔头">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          CentOS下怎样干掉IPv6
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2016-08-31 15:49:24" itemprop="dateCreated datePublished" datetime="2016-08-31T15:49:24+08:00">2016-08-31</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">更新于</span>
      <time title="修改时间：2019-04-05 07:47:06" itemprop="dateModified" datetime="2019-04-05T07:47:06+08:00">2019-04-05</time>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><h1 id="什么是IPv6"><a href="#什么是IPv6" class="headerlink" title="什么是IPv6"></a>什么是IPv6</h1><p><strong>Internet Protocol version 6</strong> (简称<strong>IPv6</strong>) 是 <a href="https://en.wikipedia.org/wiki/Internet_Protocol" target="_blank" rel="noopener">Internet Protocol（互联网协议）</a> (IP)的最新一个版本，IPv6主要是为了解决IPv4地址枯竭的问题而开发的，目的是为了替换当前所用的IPv4。</p>
<p>虽然IPv6天生是为了替代IPv4的（生而自豪），而且最近几年IPv4地址也已然分配完，但是由于NAT这种技术的存在，使得IPv6还没有真正意义上的”取代”IPv4。尤其是在“我大宋”，除了教育网有IPv6的环境以外，其他基本都不支持IPv6。不过国外貌似发展的还可以，好些运营商都已经开始支持IPv6了。<br><a id="more"></a></p>
<h1 id="IPv6的毛病"><a href="#IPv6的毛病" class="headerlink" title="IPv6的毛病"></a>IPv6的毛病</h1><p>毛病？IPv6其实没毛病，而且作为要替换IPv4的下一代协议，优点还很多。：）只是因为我们身处天朝上国，网络根本就不支持IPv6，所以即使Linux系统缺省就支持IPv6，作为崇尚洁癖的系统管理员、运维工程师们，自然是婶婶可以忍，叔叔不可忍！（是可忍，孰不可忍）。</p>
<p>好啦，以上纯属扯蛋，说正经的，刚开始的时候，如果在不支持IPv6的环境里启用IPv6协议的话，是会导致很多性能问题的，但最近些年，各种操作系统也做了不少调整，到目前其实真没发现IPv6会对性能造成多大影响。一个长期以来大家都认可的理由就是：IPv6会优于IPv4，也就是说，一个数据包在发送时首先会先尝试IPv6的网关，然后再是IPv4的。其实就算这种情况是真的，我们也是可以通过<strong>/etc/gai.conf</strong>文件来调整的。</p>
<h1 id="几种姿势"><a href="#几种姿势" class="headerlink" title="几种姿势"></a>几种姿势</h1><p>下面介绍几种在Linux系统里干掉IPv6的方法。</p>
<h2 id="sysctl大法"><a href="#sysctl大法" class="headerlink" title="sysctl大法"></a>sysctl大法</h2><p>几乎所有的Linux系统……好吧好吧，我就说我确认的吧，Debian系和RedHat系……算啦，最最最确认的就是CentOS（当然rhel也一样）下，可以在/etc/sysctl.d/目录下新建文件叫ipv6.conf（Linux系统在启动时会自动读取/etc/sysctl.conf以及/etc/sysctl.d/目录下的文件，并用sysctl -p来执行的，这里以.conf为扩展名是为了兼容CentOS7.x的系统，CentOS7.x认的是是“/etc/sysctl.d/<name>.conf”这种文件），文件的内容是：<br><figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">net.ipv6.conf.all.disable_ipv6</span> = <span class="number">1</span></span><br><span class="line"><span class="attr">net.ipv6.conf.default.disable_ipv6</span> = <span class="number">1</span></span><br></pre></td></tr></table></figure></name></p>
<p>配置完毕如果不重启机器的话，可以直接执行命令：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sysctl -p /etc/sysctl.d/ipv6.conf;</span><br></pre></td></tr></table></figure></p>
<p>强制让其生效。然后再用命令<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ip a s;</span><br></pre></td></tr></table></figure></p>
<p>看，会发现原来的很多<em>inet6</em>的地址不存在了，配置生效了！</p>
<p>但需要注意的是：这种方式并没有真正把ipv6模块从内核里清除掉，不信用命令<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">lsmod | grep -i ipv6;</span><br></pre></td></tr></table></figure></p>
<p>看，还是会有很多在用ipv6模块的。在这些模块里，又有好些并不是完全依赖ipv6模块不可的，只有极少数的是必须要ipv6模块的，所以，我们可以用后面的方法把ipv6模块以后系统还能正常工作。</p>
<h2 id="modprobe劫持"><a href="#modprobe劫持" class="headerlink" title="modprobe劫持"></a>modprobe劫持</h2><p>此法又称“釜底抽薪”，CentOS7.x下不支持，CentOS6.x下测试可用。具体原理是截获系统自动加载ipv6模块的动作，直接返回true，并且将ipv6模块加入黑名单(blacklist)。这样系统就没法通过<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">modprobe ipv6;</span><br></pre></td></tr></table></figure></p>
<p>或<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">insmod ipv6;</span><br></pre></td></tr></table></figure></p>
<p>来加载ipv6模块了。具体方法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">echo</span> -e <span class="string">"install ipv6 /bin/true\nblacklist ipv6"</span> &gt;\</span><br><span class="line">        /etc/modprobe.d/ipv6.conf;</span><br><span class="line">reboot; <span class="comment"># 这种办法必须要重启机器来完全生效</span></span><br></pre></td></tr></table></figure>
<p>机器重启过后再通过<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">lsmod | grep -i ipv6;</span><br></pre></td></tr></table></figure></p>
<p>来看是看不到ipv6模块的，表示ipv6模块已经完全被从内核里除掉。</p>
<h2 id="GRUB参数"><a href="#GRUB参数" class="headerlink" title="GRUB参数"></a>GRUB参数</h2><p>注意：此法仅适用于CentOS7.x！<br>此法的原理是在GRUB里直接将参数”ipv6.disable=1”传递给内核，这样启动时内核会根据这个参数不再加载ipv6模块。<br>具体方法是：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> grep -q <span class="string">"ipv6.disable=1"</span> /etc/default/grub</span><br><span class="line"><span class="keyword">then</span></span><br><span class="line">  <span class="built_in">echo</span> <span class="string">"\"ipv6.disable=1\" found in /etc/default/grub"</span></span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">  sed -i.ori <span class="string">'s/^GRUB_CMDLINE_LINUX="/&amp;ipv6.disable=1 /'</span> /etc/default/grub</span><br><span class="line">  /usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg</span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line"><span class="comment"># 此法自然也需要重启机器，于是：</span></span><br><span class="line">reboot</span><br></pre></td></tr></table></figure></p>
<h1 id="个人推荐的解决方案"><a href="#个人推荐的解决方案" class="headerlink" title="个人推荐的解决方案"></a>个人推荐的解决方案</h1><ul>
<li>CentOS7.x下慎用GRUB法，因为一旦用GRUB法，以后万一有某个模块需要ipv6，那非重新修改GRUB文件并重启机器不能成功的</li>
<li>CentOS6.x下的话，建议用sysctl法和modprobe法结合，如果碰到有一定要依赖于ipv6的模块要加载，直接修改/etc/modprobe.d/ipv6.conf，注释掉相关语句以后，再重新就能modprobe ipv6了</li>
</ul>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="reward-container">
  <div>请我一杯咖啡吧！</div>
  <button>
    赞赏
  </button>
  <div class="post-reward">
      <div>
        <img src="/images/wechat-reward.png" alt="老杨 微信">
        <span>微信</span>
      </div>
      <div>
        <img src="/images/alipay-reward.png" alt="老杨 支付宝">
        <span>支付宝</span>
      </div>

  </div>
</div>

          <div class="followme">
  <span>欢迎关注我的其它发布渠道</span>

  <div class="social-list">

      <div class="social-item">
          <a target="_blank" class="social-link" href="https://twitter.com/6fool">
            <span class="icon">
              <i class="fab fa-twitter"></i>
            </span>

            <span class="label">Twitter</span>
          </a>
      </div>

      <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
      </div>
  </div>
</div>

          <div class="post-tags">
              <a href="/tags/CentOS/" rel="tag"># CentOS</a>
              <a href="/tags/IPv6/" rel="tag"># IPv6</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2016/08/Linux%E4%B8%8B%E7%94%A8GRE%E9%9A%A7%E9%81%93%E7%9B%B4%E6%8E%A5%E8%81%94%E9%80%9A%E4%B8%A4%E4%B8%AA%E7%A7%81%E7%BD%91/index.html" rel="prev" title="Linux下用GRE隧道直接联通两个私网">
                  <i class="fa fa-angle-left"></i> Linux下用GRE隧道直接联通两个私网
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2016/09/Linux%E4%B8%8B%E5%9F%9F%E5%90%8D%E8%A7%A3%E6%9E%90%E7%9A%84%E4%BC%98%E5%8C%96/index.html" rel="next" title="Linux下域名解析的优化">
                  Linux下域名解析的优化 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">老杨</span>
  </div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/pisces/" rel="noopener" target="_blank">NexT.Pisces</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>
  <div class="sidebar-dimmer"></div>
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>

</body>
</html>
